package com.hackordie.operations.deletes;

import com.hackordie.commons.HackOrDieResult;
import com.hackordie.exceptions.HackOrDieException;
import com.hackordie.operations.AHackOrDieOperationComponents;

public class DeleteComponent extends AHackOrDieOperationComponents {

	private final String componentName;
	private final int componentId;

	public DeleteComponent(String componentName) {
		super();
		this.componentName = componentName;
		this.componentId = -1;
	}

	public DeleteComponent(int idComponent) {
	    this.componentName = "";
        this.componentId = idComponent;
    }

    @Override
	protected boolean checkParameters() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	protected HackOrDieResult executeOperation() throws HackOrDieException {
	    if(componentId == -1) {
	        result.setCorrect(componentDao.delete(componentName));
	    } else {
	        result.setCorrect(componentDao.delete(componentId)); 
	    }
		return result;
	}

}
